{extend name="layouts/main" /}
{block name="main"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    <a class="layui-btn" href="/admin/member/add"><i class="layui-icon"></i>添加用户</a>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>用户名</th>
                            <th>昵称</th>
                            <th>手机号</th>
                            <th>性别</th>
                            <th>邮箱</th>
                            <th>头像</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="users" id="item"}
                        <tr>
                            <td>{$item.id}</td>
                            <td>{$item.user_name|default=''}</td>
                            <td>{$item.nick_name}</td>
                            <td>{$item.user_phone}</td>
                            <td>{$item.user_gender==0?"女":"男"}</td>
                            <td>{$item.user_email|default=''}</td>
                            <td><img src="{$item.user_img??''}" style="width: 50px;height: 50px"></td>
                            <td>{$item.create_time}</td>
                            <td>
                                <a href="/admin/member/add/{$item.id}"><i class="iconfont" title="编辑">&#xe69e;</i></a>&nbsp;&nbsp;
                                <a  href="javascript:;" onclick="delConfirm({$item.id})"><i class="iconfont" style="color: red" title="删除">&#xe69d;</i></a>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>
                    {empty name="users"}
                    暂无数据
                    {/empty}
                    <div class="page">{$users|raw}</div>
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    layui.use('layer', function(){
        var layer = layui.layer;
    });

    function delConfirm(id){
        layer.confirm('确定要删除此数据么?',function (){
                $.ajax({
                    type: "post",
                    url: "/admin/member/delete/"+id,
                    success: function (data) {
                        console.log(data.status);
                        if (data.status == 200) {
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function () {
                                window.location.reload();
                            });
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                });
            }
        );
    }
</script>
{/block}
